/* 
	1. 目的： 提供解析复杂数据的函数

*/ 


function getPathData(obj, path) {
    path = (path+'').trim();
    if(!path) return '';
    path = path.split('.');
    let prop;
    let res = obj;
    let array = [];
    let pathArray;

    
    while(prop = path.shift()) {
        if (prop.search(/\[\d\]/g) < 0) {   // 表明不存在数组
            res = res[prop];
        }
        else {
            pathArray = prop.split('[');
            res = getPathData1(res[pathArray.shift()], pathArray)
        }
    }

    return res;
}


function getPathData1(array, path) {
    let res = array;
    let prop;
    let index;
    while(prop = path.shift()) {
        index = prop.match(/\d/);
        res = res[index - 0];
    }
    return res;
}